<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="3">
        <div class="left-side-box">
          <div class="left-title" onselectstart="return false">会议信息</div>
          <div class="left-select">
            <span onselectstart="return false">版本年限</span>
            <el-select v-model="selectedVersion" placeholder="请选择版本类型" size="small" style="width: 125px;">
              <el-option v-for="ver in versionList" :label="ver.version" :value="ver.id"/>
            </el-select>
          </div>
          <div v-for="meetingType in meetingTypeOptions" :key="meetingType.id" @click="handleMeetingTypeSelect(meetingType)"
               class="left-item" :class="{'selected': selectedMeeting.id === meetingType.id}" onselectstart="return false">
            <div>{{meetingType.label}}</div>
            <div style="width: 30px; height: 20px; border-radius: 8px; background: #E9EDF4; line-height: 20px;">
              {{meetingType.value}}
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="21">
        <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
          <el-form-item label="会议名称" prop="mettingName">
            <el-input
              v-model="queryParams.mettingName"
              placeholder="请输入会议名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="会议状态" prop="mettingType">
            <el-select v-model="queryParams.mettingType" placeholder="请选择会议类型" clearable size="small">
              <el-option label="请选择字典生成" value="" />
            </el-select>
          </el-form-item>
          <el-form-item label="企业名称" prop="mettingType">
            <el-select v-model="queryParams.mettingType" placeholder="请选择会议类型" clearable size="small">
              <el-option label="请选择字典生成" value="" />
            </el-select>
          </el-form-item>
          <el-form-item label="创建时间" prop="mettingDate">
            <el-date-picker clearable size="small" style="width: 200px"
                            v-model="queryParams.mettingDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择会议日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['system:metting:add']"
            >新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              size="mini"
              :disabled="single"
              @click="handleReport"
            >上报</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleBatchImport"
            >批量导入</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['system:metting:export']"
            >导出</el-button>
          </el-col>
        </el-row>

        <el-table v-loading="loading" :data="mettingList" border @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" type="index" width="55" align="center" />
          <el-table-column label="校验" width="55" align="center" />
          <el-table-column label="会议名称" align="center" prop="mettingName" />
          <el-table-column label="会议类型" align="center" prop="mettingType" />
          <el-table-column label="企业名称" align="center" prop="companyName" />
          <el-table-column label="主持人" align="center" prop="mettingHost" />
          <el-table-column label="会议时间" align="center" prop="summaryDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.summaryDate) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center" prop="summaryDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.summaryDate) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="状态" width="80" align="center" prop="status"/>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="edit" @click="handleMeetingUpdate(scope.row)"></svg-icon>
              <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="report" @click="handleMeetingReport(scope.row)"></svg-icon>
              <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="revoke" @click="handleMeetingRevoke(scope.row)"></svg-icon>
              <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="preview" @click="handleMeetingDetail(scope.row)"></svg-icon>
              <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="delete" @click="handleMeetingDelete(scope.row)"></svg-icon>
              <svg-icon style="cursor: pointer;" icon-class="approval" @click="handleMeetingApproval(scope.row)"></svg-icon>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <!-- 批量导入 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" style="margin-top: 15vh"
               width="400px" @close="handleBatchClose">
      <div style="height: 20px;"></div>
      <el-upload
        ref="batchUpload"
        :limit="1"
        accept=".xlsx, .xls"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-success="handleBatchSuccess"
        :auto-upload="false"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-link type="info" style="font-size:12px; color: #1890FF;" @click="download('group1/M00/00/00/rBBqSV82EFWAMTFaAABuAOIytHk382.xls')">下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！只能导入一个文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitBatchForm">导 入</el-button>
        <el-button @click="cancelBatch">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改 会议信息 对话框 -->
    <el-dialog :title="meeting.title" :visible.sync="meeting.open" append-to-body @close="handleMeetingClose" width="800px">
      <div style="font-size: 16px; color: #14284A; padding: 30px 10px 10px 10px; font-weight: 700;">
        <svg-icon icon-class="company"></svg-icon>
        安徽省交通控股集团有限公司
      </div>
      <el-steps :active="meeting.active" finish-status="success" space="400px" :align-center="true" style="margin-bottom: 20px">
        <el-step title="会议基础信息"></el-step>
        <el-step title="议题信息"></el-step>
      </el-steps>
      <el-form ref="meetingForm" :model="meeting.form" :rules="meeting.rules" label-width="110px">
        <el-row v-show="meeting.active === 0">
          <el-row>
            <el-col :span="24">
              <el-form-item :disabled="!meeting.modify" label="会议名称" prop="mettingName">
                <el-input v-model="meeting.form.mettingName" placeholder="请输入会议名称" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="会议类型" prop="mettingType">
                <el-select :disabled="!meeting.modify"  v-model="meeting.form.mettingType" placeholder="请选择会议类型" style="width: 100%">
                  <el-option v-if="type.id != 0" v-for="type in meetingTypeOptions" :key="type.label" :label="type.label" :value="type.label" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="会议形式" prop="mettingForm">
                <el-select :disabled="!meeting.modify"  v-model="meeting.form.mettingFormArr" placeholder="请选择会议形式（多选）" multiple style="width: 100%">
                  <el-option v-for="mf in meetingFormOptions" :key="mf.id" :label="mf.label" :value="mf.label" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="会议时间" prop="mettingDate">
                <el-date-picker :disabled="!meeting.modify"  clearable size="small" style="width: 100%"
                                v-model="meeting.form.mettingDate"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择会议日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="纪要印发时间" prop="summaryDate">
                <el-date-picker :disabled="!meeting.modify"  clearable size="small" style="width: 100%"
                                v-model="meeting.form.summaryDate"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择会议纪要印发日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col v-if="false" :span="12">
              <el-form-item label="会议地点" prop="mettingArea">
                <el-input :disabled="!meeting.modify"  v-model="meeting.form.mettingArea" clearable placeholder="请输入会议地点" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="会议编码" prop="mettingCode">
                <el-input v-model="meeting.form.mettingCode" disabled placeholder="提交后系统自动生成" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input :disabled="!meeting.modify" v-model="meeting.form.remark" type="textarea" clearable placeholder="请输入备注信息"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <p style="width: 200px; color: #606266; padding-left: 35px; font-size: 14px; font-weight: 700; line-height: 36px; text-align: left;">
                <span style="color: #ff4949">*</span> 选择列席人员和主持人
              </p>
              <div style="margin: 0 auto; width: 400px; min-height: 300px; border: 1px dashed #d9d9d9;">
                <div style="padding: 20px 0;">
                  <div style="position: relative; margin: auto; padding-top: 15px; width: 50px; height: 50px; text-align: center; background: #FAFCFD; border: 1px dashed #DAE1ED; border-radius: 4px;">
                    <svg-icon icon-class="user-1" width="26" height="20"></svg-icon>
                    <svg-icon icon-class="plus" width="20" height="20" style="position: absolute; top: -10px; right: -10px;"></svg-icon>
                  </div>
                </div>
                <el-table :data="meeting.meetingHostList">
                  <el-table-column label="列席人员" align="center">
                    <template slot-scope="scope">
                      <div style="display: flex; align-items: center;justify-content: center">
                        <img :src="scope.row.isAttend === 1 ? userAttendPng : userAbsentPng" width="32"
                             @click="handleHostEdit(scope, 'meeting')" alt="是否出席"/>
                        <span style="margin-left: 5px;">{{scope.row.name}}</span>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column label="指定主持人" align="center">
                    <template slot-scope="scope">
                      <i v-if="scope.row.isCompere === 1" class="el-rate__icon el-icon-star-on" style="color: rgb(247, 186, 42);" @click="scope.row.isCompere = 0"></i>
                      <i v-else class="el-rate__icon el-icon-star-off" style="color: rgb(198, 209, 222);" @click="scope.row.isCompere = 1"></i>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-col>
          </el-row>
          <el-row style="margin-top: 20px;">
            <el-form-item label="正式文件" prop="noticeFile">
              <div style="width: 400px;">
                <el-upload drag v-if="meeting.modify"
                           :action="uploadUrl"
                           :on-success="handleNoticeFile"
                           :show-file-list="false">
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                </el-upload>
                <div style="display: flex; flex-flow: column nowrap">
                  <div v-for="(verFile, idx) in meeting.noticeFileList" :key="idx">
                    <div style="float: left">{{verFile.realName}}</div>
                    <el-button type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="download(verFile.url)">
                      <svg-icon icon-class="file-download"></svg-icon>
                      下载
                    </el-button>
                    <el-button v-if="meeting.modify" type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="handleNoticeRemove(idx)">
                      <svg-icon icon-class="delete"></svg-icon>
                      删除
                    </el-button>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="辅证材料" prop="summaryFile">
              <div style="width: 400px">
                <el-upload drag v-if="meeting.modify"
                           :action="uploadUrl"
                           :on-success="handleSummaryFile"
                           :show-file-list="false">
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                </el-upload>
                <div style="display: flex; flex-flow: column nowrap">
                  <div v-for="(verFile, idx) in meeting.summaryFileList" :key="idx">
                    <div style="float: left">{{verFile.realName}}</div>
                    <el-button type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="download(verFile.url)">
                      <svg-icon icon-class="file-download"></svg-icon>
                      下载
                    </el-button>
                    <el-button v-if="meeting.modify" type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="handleSummaryRemove(idx)">
                      <svg-icon icon-class="delete"></svg-icon>
                      删除
                    </el-button>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-row>
        </el-row>
        <el-row v-show="meeting.active === 1">
          <el-row>
            议题列表
            <el-button v-if="meeting.modify" type="text" icon="el-icon-circle-plus" @click="handleAgendaAdd">新增</el-button>
          </el-row>
          <el-row>
            <el-table :data="meeting.agendaList" border>
              <el-table-column label="序号" type="index" align="center" width="55"/>
              <el-table-column label="议题名称" prop="agendaName" align="center"/>
              <el-table-column v-if="false" label="正常/异常" prop="" align="center"/>
              <el-table-column label="议题编码" prop="agendaCode" align="center"/>
              <el-table-column label="报国资委/上级" prop="reportable" align="center"/>
              <el-table-column label="是否通过" prop="passable" align="center"/>
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <svg-icon style="margin-right:8px; cursor:pointer;" icon-class="preview" @click="handleAgendaDetail(scope)"></svg-icon>
                  <svg-icon v-if="meeting.modify" style="margin-right:8px; cursor:pointer;" icon-class="delete" @click="handleAgendaDelete(scope)"></svg-icon>
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelMeeting">取 消</el-button>
        <el-button v-if="meeting.modify" @click="cancelMeeting">暂 存</el-button>
        <el-button v-show="meeting.modify && meeting.active === 1" type="primary" @click="submitMeetingForm">提交审核</el-button>
        <el-button v-show="meeting.active !== 1" type="primary" @click="handleStepNext">下一步</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改 议题信息 对话框 -->
    <el-dialog :title="agenda.title" :visible.sync="agenda.open" append-to-body @close="handleAgendaClose" width="800px">
      <div style="font-size: 16px; color: #14284A; padding: 30px 10px 10px 10px; font-weight: 700;">
        <svg-icon icon-class="company"></svg-icon>
        安徽省交通控股集团有限公司
      </div>
      <el-steps :active="agenda.active" finish-status="success" space="400px" :align-center="true" style="margin-bottom: 20px">
        <el-step title="会议基础信息"></el-step>
        <el-step title="议题信息"></el-step>
      </el-steps>
      <el-form ref="agendaForm" :model="agenda.form" :rules="agenda.rules" label-width="120px">
        <el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="议题名称" prop="agendaName">
                <el-input v-model="agenda.form.agendaName" placeholder="请输入议题名称" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="关联事项" prop="itemCode">
                <el-select v-model="agenda.form.itemCode" placeholder="请选择关联事项" style="width: 100%">
                  <el-option v-for="item in itemList" :label="item.itemName" :value="item.itemCode" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联议题" prop="agendaCodeList">
                <el-select v-model="agenda.relatedAgendaCodeArr" placeholder="请选择关联议题" multiple style="width: 100%">
                  <el-option v-for="mf in meetingFormOptions" :key="mf.id" :label="mf.label" :value="mf.label" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="任务来源" prop="agendaResource">
                <el-select v-model="agenda.form.agendaResource" placeholder="请选择任务来源" style="width: 100%">
                  <el-option label="请选择字典生成" value="" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="专题名称" prop="specialItemName">
                <el-select v-model="agenda.form.specialItemName" placeholder="请选择专题名称" style="width: 100%">
                  <el-option v-for="mf in specialItemOptions" :key="mf.id" :label="mf.label" :value="mf.label" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="是否通过" prop="passable">
                <el-select v-model="agenda.form.passable" placeholder="请选择是否通过" style="width: 100%">
                  <el-option v-for="option in passableOptions" :key="option.id" :label="option.label" :value="option.label" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="上报国资委/上级" prop="reportable">
                <el-select v-model="agenda.form.reportable" placeholder="请选择是否上报" style="width: 100%">
                  <el-option v-for="mf in reportableOptions" :key="mf.id" :label="mf.label" :value="mf.label" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="是否督办" prop="superviseable">
                <el-select v-model="agenda.form.superviseable" placeholder="请选择是否督办" style="width: 100%">
                  <el-option label="是" value="是" />
                  <el-option label="否" value="否" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否听取意见" prop="consultable">
                <el-select v-model="agenda.form.consultable" placeholder="请选择是否听取意见" style="width: 100%">
                  <el-option label="是" value="是" />
                  <el-option label="否" value="否" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="议题决议" prop="agendaDecision">
              <el-input v-model="agenda.form.agendaDecision" type="textarea" placeholder="请输入议题决议"/>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="agenda.form.remark" type="textarea" placeholder="请输入备注信息"/>
            </el-form-item>
          </el-row>
          <el-row>
            <el-col :span="24">
              <p style="width: 210px; color: #606266; font-size: 14px; font-weight: 700; line-height: 36px; text-align: right;">
                <span style="color: #ff4949">*</span> 选择列席人员和投票结果
              </p>
              <div style="margin-left: 130px;width: 400px; min-height: 300px; border: 1px dashed #d9d9d9;">
                <div style="padding: 20px 0;">
                  <div style="position: relative; margin: auto; padding-top: 15px; width: 50px; height: 50px; text-align: center; background: #FAFCFD; border: 1px dashed #DAE1ED; border-radius: 4px;">
                    <svg-icon icon-class="user-1" width="26" height="20"></svg-icon>
                    <svg-icon icon-class="plus" width="20" height="20" style="position: absolute; top: -10px; right: -10px;"></svg-icon>
                  </div>
                </div>
                <el-table :data="agenda.meetingHostList">
                  <el-table-column label="列席人员" align="center">
                    <template slot-scope="scope">
                      <div style="display: flex; align-items: center;justify-content: center">
                        <img :src="scope.row.isAttend === 1 ? userAttendPng : userAbsentPng" width="32"
                             @click="handleHostEdit(scope, 'agenda')" alt="是否出席"/>
                        <span style="margin-left: 5px;">{{scope.row.name}}</span>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column label="投票结果" align="center">
                    <template slot-scope="scope">
                      <div>{{scope.row.result}}</div>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-form-item label="意见文件" prop="suggestionFileList" style="margin-top: 20px;">
              <div class="upload-demo">
                <el-upload drag v-if="agenda.modify"
                           :action="uploadUrl"
                           :on-success="handleSuggestionFile"
                           :show-file-list="false">
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                </el-upload>
                <div style="display: flex; flex-flow: column nowrap">
                  <div v-for="(verFile, idx) in agenda.suggestionFileList" :key="idx">
                    <div style="float: left">{{verFile.realName}}</div>
                    <el-button type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="download(verFile.url)">
                      <svg-icon icon-class="file-download"></svg-icon>
                      下载
                    </el-button>
                    <el-button v-if="agenda.modify" type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="handleSuggestionRemove(idx)">
                      <svg-icon icon-class="delete"></svg-icon>
                      删除
                    </el-button>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="议题材料" prop="agendaFileList">
              <div class="upload-demo">
                <el-upload drag v-if="agenda.modify"
                           :action="uploadUrl"
                           :on-success="handleAgendaFile"
                           :show-file-list="false">
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                </el-upload>
                <div style="display: flex; flex-flow: column nowrap">
                  <div v-for="(verFile, idx) in agenda.agendaFileList" :key="idx">
                    <div style="float: left">{{verFile.realName}}</div>
                    <el-button type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="download(verFile.url)">
                      <svg-icon icon-class="file-download"></svg-icon>
                      下载
                    </el-button>
                    <el-button v-if="agenda.modify" type="text" style="color: #666666; float: right; margin:0 15px 0 0;" @click="handleAgendaRemove(idx)">
                      <svg-icon icon-class="delete"></svg-icon>
                      删除
                    </el-button>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-row>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelAgenda">取 消</el-button>
        <el-button v-if="agenda.modify" @click="cancelAgenda">暂 存</el-button>
        <el-button v-if="agenda.modify" type="primary" @click="submitAgendaForm">提交审核</el-button>
      </div>
    </el-dialog>

    <!-- 修改参会人员状态 -->
    <el-dialog :title="participant.title" :visible.sync="participant.open" style="margin-top: 15vh"
               append-to-body @close="handleParticipantClose" width="400px">
      <el-form ref="participantForm" :model="participant.form" :rules="participant.rules" label-width="100px">
        <el-row>
          <el-form-item label="是否出席" prop="isAttend">
            <el-radio-group v-model="participant.form.isAttend" placeholder="请选择是否出席">
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-row>
        <el-row v-if="participant.type === 'agenda'">
          <el-form-item label="投票意见" prop="result">
            <el-radio-group v-model="participant.form.result" placeholder="请选择投票意见">
              <el-radio label="同意">同意</el-radio>
              <el-radio label="保留意见">保留意见</el-radio>
              <el-radio label="原则同意">原则同意</el-radio>
              <el-radio label="不同意">不同意</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-row>
        <el-row v-show="participant.form.isAttend === 0">
          <el-form-item label="请假原因" prop="reason">
            <el-input v-model="participant.form.reason" type="textarea" placeholder="请输入请假原因"/>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelParticipant">取 消</el-button>
        <el-button type="primary" @click="submitParticipantForm">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMetting, getMetting, delMetting, addMetting, updateMetting, exportMetting } from "@/api/szyd/metting";
import { listAgenda, getAgenda, addAgenda, updateAgenda, delAgenda, exportAgenda } from "@/api/szyd/agenda";
import { getItem, listItem } from "@/api/szyd/item";
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/szyd/info";
import { listVersion } from "@/api/szyd/version";

import userAbsentPng from '@/assets/image/user-absent.png'
import userAttendPng from '@/assets/image/user-attend.png'

export default {
  name: "Metting",
  data() {
    return {
      userAbsentPng,
      userAttendPng,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 会议信息 表格数据
      mettingList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        mettingName: undefined,
        mettingCode: undefined,
        mettingType: undefined,
        mettingForm: undefined,
        mettingDate: undefined,
        mettingHost: undefined,
        participant: undefined,
        mettingNotice: undefined,
        mettingSummary: undefined,
        summaryDate: undefined
      },
      // 文件上传借口
      uploadUrl: process.env.VUE_APP_BASE_API + '/szyd/upload',
      // 批量导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "事项清单批量导入",
        // 是否禁用上传
        isUploading: false,
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/szyd/metting/importData'
      },

      // 会议信息
      meeting: {
        open: false,
        modify: false,
        title: '',
        active: 0,
        form: {},
        // 列席人员
        meetingHostList: [{
          id: 0,
          name: '张思思',
          isAttend: 1,
          isCompere: 0,
          reason: '',
          result: ''
        }],
        // 会议通知文件
        noticeFileList: [],
        // 会议纪要文件
        summaryFileList: [],
        // 议题列表
        agendaList: [],
        rules: {
          mettingName: [
            { required: true, message: "请输入会议名称", trigger: "blur" }
          ],
          mettingType: [
            { required: true, message: "请选择会议类型", trigger: "blur" }
          ],
          mettingFormArr: [
            { required: true, message: "请选择会议形式", trigger: "blur" }
          ],
          mettingDate: [
            { required: true, message: "请选择会议时间", trigger: "blur" }
          ],
          summaryDate: [
            { required: true, message: "请选择会议纪要印发时间", trigger: "blur" }
          ],
          mettingArea: [
            { required: false, message: "请输入会议地址", trigger: "blur" }
          ],
          mettingHost: [
            { required: true, message: "请添加会议主持人", trigger: "blur" }
          ],
          participant: [
            { required: true, message: "请添加会议参会人", trigger: "blur" }
          ],
          noticeFile: [
            { required: false, message: "请添加正式文件", trigger: "blur" }
          ],
          summaryFile: [
            { required: false, message: "请添加辅证材料", trigger: "blur" }
          ]
        }
      },

      // 议题信息
      agenda: {
        open: false,
        modify: false,
        title: '',
        active: 1,
        form: {},
        index: null,
        relatedAgendaCodeArr: [],
        // 列席人员
        meetingHostList: [{
          id: 0,
          name: '张思思',
          isAttend: 1,
          isCompere: 0,
          reason: '',
          result: ''
        }],
        // 议题材料
        agendaFileList: [],
        // 意见文件
        suggestionFileList: [],
        rules: {
          agendaName: [
            { required: true, message: "请输入议题名称", trigger: "blur" }
          ],
          itemCode: [
            { required: true, message: "请选择关联事项", trigger: "blur" }
          ],
          agendaFileList: [
            { required: false, message: "请添加议题材料", trigger: "blur" }
          ],
          summaryFileList: [
            { required: true, message: "请选择是否经合法审核", trigger: "blur" }
          ]
        }
      },

      // 出席人员
      participant: {
        open: false,
        title: '修改状态',
        form: {},
        index: 0,
        type: 'meeting',
        rules: {
          isAttend: [
            { required: true, message: "请选择是否出席", trigger: "blur" }
          ],
          result: [
            { required: true, message: "请选择投票意见", trigger: "blur" }
          ],
          reason: [
            { required: true, message: "请输入请假原因", trigger: "change" }
          ],
        }
      },

      itemList: [],
      versionList: [],
      selectedVersion: {},
      selectedMeeting: {
        'id': 0,
        'label': '全部',
        'value': '20'
      },
      // 会议类型
      meetingTypeOptions: [
        {
          'id': 0,
          'label': '全部',
          'value': '20'
        },{
          'id': 1,
          'label': '党委会',
          'value': '1'
        },{
          'id': 2,
          'label': '职代会',
          'value': '3'
        },{
          'id': 3,
          'label': '党组会',
          'value': '4'
        },{
          'id': 4,
          'label': '董事会',
          'value': '2'
        },{
          'id': 5,
          'label': '经理层办公会',
          'value': '10'
        },{
          'id': 6,
          'label': '股东会',
          'value': '0'
        },{
          'id': 7,
          'label': '党委（党组）会',
          'value': '0'
        },{
          'id': 8,
          'label': '其他',
          'value': '0'
        },
      ],
      // 会议形式
      meetingFormOptions: [
        {
          'id': 1,
          'label': '传签会议',
        },{
          'id': 2,
          'label': '电视电话会议',
        },{
          'id': 3,
          'label': '现场会议',
        },{
          'id': 4,
          'label': '学习会议',
        }
      ],
      // 专题名称类型
      specialItemOptions: [
        {
          'id': 0,
          'label': '精准扶贫',
        },{
          'id': 1,
          'label': '援疆援藏',
        },{
          'id': 2,
          'label': '党风廉政建设',
        },{
          'id': 3,
          'label': '提速降费',
        },
      ],
      // 是否通过
      passableOptions: [
        {
          'id': 0,
          'label': '通过',
        },{
          'id': 1,
          'label': '缓议',
        },{
          'id': 2,
          'label': '否决',
        },
      ],
      // 是否上报
      reportableOptions: [
        {
          'id': 0,
          'label': '备案',
        },{
          'id': 1,
          'label': '审批',
        },{
          'id': 2,
          'label': '否',
        },
      ],
    };
  },
  created() {
    this.getVersionList()
    this.getItemList()
  },
  methods: {
    handleMeetingTypeSelect(infoType) {
      this.selectedMeeting = infoType
      this.getList()
    },
    getVersionList() {
      listVersion().then(res => {
        if (res && res.code === 200) {
          this.versionList = res.data
          if (res.data && res.data.length > 0) {
            this.selectedVersion = res.data[0]
            this.getList()
          }
        }else {
          this.msgError(res.msg)
        }
      }).catch(err => {
        this.msgError(err)
      })
    },
    getItemList() {
      listItem().then(res => {
        if (res.code === 200) {
          this.itemList = res.data
        }
      }).then(err => {

      })
    },
    /** 查询 会议信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.mettingType = this.selectedMeeting.id === 0 ? null : this.selectedMeeting.label
      listMetting(this.queryParams).then(response => {
        this.mettingList = response.data;
        this.total = response.total;
        this.loading = false;
      }).catch(err => {
        this.loading = false
        this.msgSuccess(err)
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !=1
      this.multiple = !selection.length
    },
    /** 上报 */
    handleReport() {

    },
    /** 上报 */
    handleMeetingReport(row) {

    },
    /** 撤回 */
    handleMeetingRevoke(row) {

    },
    /** 审批 */
    handleMeetingApproval(row) {

    },
    /** ----------------------------------------------批量导入-------------------------------------------------------- */
    /** 批量导入 */
    handleBatchImport() {
      this.upload.open = true
    },
    handleBatchClose() {
      this.$refs['batchUpload'].clearFiles()
    },
    handleBatchSuccess() {
      this.upload.open = false
    },
    // 取消事项清单批量导入
    cancelBatch() {
      this.upload.open = false
    },
    // 事项清单批量导入
    submitBatchForm() {
      this.$refs['batchUpload'].submit()
    },
    /** ----------------------------------------------添加/修改会议信息-------------------------------------------------------- */
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.meeting.open = true;
      this.meeting.modify = true
      this.meeting.title = "添加会议信息";
    },
    /** 表单重置 */
    reset() {
      this.meeting.form = {
        id: undefined,
        mettingName: undefined,
        mettingCode: undefined,
        mettingType: undefined,
        mettingForm: undefined,
        mettingFormArr: undefined,
        mettingDate: undefined,
        mettingHost: undefined,
        participant: undefined,
        mettingNotice: undefined,
        mettingSummary: undefined,
        summaryDate: undefined
      };
      this.resetForm("meetingForm");
    },
    /** 关闭 会议信息 弹窗 */
    cancelMeeting() {
      this.meeting.open = false;
    },
    /** 会议信息弹窗关闭回掉 */
    handleMeetingClose() {
      this.reset()
      this.meeting.active = 0
      this.meeting.form = {}
      this.meeting.noticeFileList = []
      this.meeting.summaryFileList = []
      this.meeting.agendaList = []
    },
    /** 修改按钮操作 */
    handleMeetingUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getMetting(id).then(response => {
        this.meeting.form = response.data;
        // 会议形式
        this.meeting.form.mettingFormArr = JSON.parse(this.meeting.form.mettingForm) || []
        // 参会人员
        this.meeting.meetingHostList = JSON.parse(this.meeting.form.participant)
        // 会议通知文件
        this.meeting.noticeFileList = JSON.parse(this.meeting.form.mettingNotice)
        // 会议纪要文件
        this.meeting.summaryFileList = JSON.parse(this.meeting.form.mettingSummary)
        // 议题列表
        this.meeting.agendaList = response.data.agendaList
        this.meeting.title = "修改会议信息";
        this.meeting.modify = true
        this.meeting.open = true;
      });
    },
    /** 详情 */
    handleMeetingDetail(row) {
      this.reset();
      const id = row.id || this.ids
      getMetting(id).then(response => {
        this.meeting.form = response.data;
        // 会议形式
        this.meeting.form.mettingFormArr = JSON.parse(this.meeting.form.mettingForm) || []
        // 参会人员
        this.meeting.meetingHostList = JSON.parse(this.meeting.form.participant)
        // 会议通知文件
        this.meeting.noticeFileList = JSON.parse(this.meeting.form.mettingNotice)
        // 会议纪要文件
        this.meeting.summaryFileList = JSON.parse(this.meeting.form.mettingSummary)
        // 议题列表
        this.meeting.agendaList = response.data.agendaList
        this.meeting.title = '会议信息详情'
        this.meeting.modify = false
        this.meeting.open = true;
      });
    },
    /** 删除 */
    handleMeetingDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return delMetting(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(function() {});
    },
    /** 添加 会议通知文件 */
    handleNoticeFile(res, file, fileList) {
      console.log(res, file, fileList)
      let {code, realName, url} = res
      if (code === 200) {
        this.meeting.noticeFileList.push({
          realName,
          url
        })
      }
    },
    /** 删除 会议通知文件 */
    handleNoticeRemove(index) {
      this.meeting.noticeFileList.splice(index, 1)
    },
    /** 添加 会议纪要文件 */
    handleSummaryFile(res, file, fileList) {
      // console.log(res, file, fileList)
      let {code, realName, url} = res
      if (code === 200) {
        this.meeting.summaryFileList.push({
          realName,
          url
        })
      }
    },
    /** 删除 会议纪要文件 */
    handleSummaryRemove(index) {
      this.meeting.summaryFileList.splice(index, 1)
    },
    handleStepNext() {
      if (this.meeting.modify) {
        // 会议形式
        this.meeting.form.mettingForm = JSON.stringify(this.meeting.form.mettingFormArr) || ""
        // 参会人员
        this.meeting.form.participant = JSON.stringify(this.meeting.meetingHostList) || ""
        // 会议通知文件
        this.meeting.form.mettingNotice = JSON.stringify(this.meeting.noticeFileList) || ""
        // 会议纪要文件
        this.meeting.form.mettingSummary = JSON.stringify(this.meeting.summaryFileList) || ""
        this.$refs['meetingForm'].validate(valid => {
          if (valid) {
            if (this.meeting.active++ > 1) {
              this.meeting.active = 0
            }
          }
        })
      } else {
        if (this.meeting.active++ > 1) {
          this.meeting.active = 0
        }
      }
    },
    /** 提交按钮 */
    submitMeetingForm: function() {
      this.$refs["meetingForm"].validate(valid => {
        if (valid) {
          // 会议议题列表
          this.meeting.form.agendaList = this.meeting.agendaList || []

          if (this.meeting.form.id != undefined) {
            updateMetting(this.meeting.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.meeting.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            addMetting(this.meeting.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.meeting.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },
    /** ---------------------------------------------议题信息---------------------------------------------------------- */
    /** 添加议题信息 */
    handleAgendaAdd() {
      this.resetAgenda();
      this.agenda.index = null
      this.agenda.open = true;
      this.agenda.modify = true
      this.agenda.title = "添加议题信息";
    },
    /** 查看议题信息详情 */
    handleAgendaDetail(scope) {
      let { row, $index } = scope
      this.agenda.form = row
      this.agenda.index = $index
      // 关联议题
      this.agenda.relatedAgendaCodeArr = JSON.parse(this.agenda.form.relatedAgendaCode) || []
      // 参会人员
      this.agenda.meetingHostList = JSON.parse(this.agenda.form.participant)
      // 议题意见文件
      this.agenda.suggestionFileList = JSON.parse(this.agenda.form.consultFile)
      // 议题材料
      this.agenda.agendaFileList = JSON.parse(this.agenda.form.agendaFile)
      this.agenda.title = '会议信息详情'
      this.agenda.open = true
      this.agenda.modify = false
    },
    /** 删除议题信息 */
    handleAgendaDelete(scope) {
      let { row, $index } = scope
      this.meeting.agendaList.splice($index, 1)
    },
    /** 添加 会议通知文件 */
    handleSuggestionFile(res, file, fileList) {
      console.log(res, file, fileList)
      let {code, realName, url} = res
      if (code === 200) {
        this.agenda.suggestionFileList.push({
          realName,
          url
        })
      }
    },
    /** 删除 会议通知文件 */
    handleSuggestionRemove(index) {
      this.agenda.suggestionFileList.splice(index, 1)
    },
    /** 添加 会议纪要文件 */
    handleAgendaFile(res, file, fileList) {
      // console.log(res, file, fileList)
      let {code, realName, url} = res
      if (code === 200) {
        this.agenda.agendaFileList.push({
          realName,
          url
        })
      }
    },
    /** 删除会议纪要文件 */
    handleAgendaRemove(index) {
      this.agenda.agendaFileList.splice(index, 1)
    },
    // 表单重置
    resetAgenda() {
      this.agenda.form = {
        id: undefined,
        agendaName: undefined,
        itemCode: undefined,
        agendaCode: undefined,
        agendaResource: undefined,
        relatedAgendaCode: undefined,
        specialItemName: undefined,
        passable: undefined,
        participant: undefined,
        reportable: undefined,
        superviseable: undefined,
        consultable: undefined,
        agendaDecision: undefined,
        remark: undefined,
      };
      this.agenda.suggestionFileList = []
      this.agenda.agendaFileList = []
      this.resetForm("agendaForm");
    },
    handleAgendaClose() {
      this.resetAgenda()
    },
    cancelAgenda() {
      this.agenda.open = false
    },
    submitAgendaForm() {
      this.$refs["agendaForm"].validate(valid => {
        if (valid) {
          // 关联议题
          this.agenda.form.relatedAgendaCode = JSON.stringify(this.agenda.relatedAgendaCodeArr)
          // 参会人员
          this.agenda.form.participant = JSON.stringify(this.agenda.meetingHostList)
          // 意见文件
          this.agenda.form.consultFile = JSON.stringify(this.agenda.suggestionFileList)
          // 议题材料
          this.agenda.form.agendaFile = JSON.stringify(this.agenda.agendaFileList)

            // addAgenda(this.agenda.form).then(response => {
            //   if (response.code === 200) {
                this.agenda.open = false;
                this.meeting.agendaList.push(Object.assign({}, this.agenda.form))
                // this.msgSuccess("新增成功");
                // this.getList();
              // } else {
              //   this.msgError(response.msg);
              // }
            // });
        }
      });
    },
    /** ----------------------------------------------参会人员状态修改-------------------------------------------------- */
    /** 是否出席 */
    handleHostEdit(scope, type) {
      console.log('handleHostEdit: ', scope)
      if (this.meeting.modify) {
        let {row, $index} = scope
        this.participant.form = row
        this.participant.index = $index
        this.participant.type = type
        this.participant.open = true
      }
    },
    handleParticipantClose() {
      this.participant.form = {}
    },
    cancelParticipant() {
      this.participant.open = false
    },
    submitParticipantForm() {
      if (this.participant.form.isAttend === 0 && !this.participant.form.reason) {
        this.msgError('请输入请假原因')
        return
      }
      if (this.participant.form.isAttend === 1 && this.participant.type === 'agenda' && !this.participant.form.result) {
        this.msgError('请选择投票意见')
        return
      }
      if (this.participant.type === 'meeting') {
        this.$set(this.meeting.meetingHostList, this.participant.index, this.participant.form)
      }
      if (this.participant.type === 'agenda') {
        this.$set(this.agenda.meetingHostList, this.participant.index, this.participant.form)
      }
      this.participant.open = false
    },
    /** ------------------------------------------------------------------------------------------------------------- */
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有【请填写功能名称】数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportMetting(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>
<style lang="scss" scoped>

  .left-side-box {
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    height: calc(100vh - 125px);
    background: white;
    text-align: center;
    border-radius: 5px;

    .left-title {
      position: relative;
      width: 100%;
      height: 50px;
      font-size: 14px;
      line-height: 50px;
      color: white;
      background-color: #374261;
      border-radius: 5px 5px 0 0
    }

    .left-select {
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 50px;
      padding: 10px 0;
      font-size: 14px;
      color: #1F1F1F;
    }

    .left-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: relative;
      width: 98%;
      height: 36px;
      padding: 0 10px;
      font-size: 12px;
      color: #14284A;
      line-height: 40px;
      margin-top: 5px;
      cursor: pointer;
    }

    .selected {
      background: #F1F2F4;
      border-radius: 4px;
    }
  }
</style>
